package com.softer.wxzj.controller;

import com.github.pagehelper.PageInfo;
import com.softer.wxzj.common.aop.annotation.LogRecord;
import com.softer.wxzj.common.aop.enums.LogOperationType;
import com.softer.wxzj.common.aop.enums.LogOperationUnit;
import com.softer.wxzj.common.entity.CommonResult;
import com.softer.wxzj.common.entity.Page;
import com.softer.wxzj.entity.*;
import com.softer.wxzj.service.DepositContinuationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 续交
 *
 * @author Gong Zhiyang
 * @date 2020/8/5
 */
@RestController
@RequestMapping("/depositContinuation")
public class DepositContinuationController {
    @Autowired
    private DepositContinuationService depositContinuationService;

    /**
     * 查询续交小区列表
     *
     * @param page           分页信息
     * @param baseRegionInfo 查询信息
     * @return 续交小区列表
     */
    @PostMapping("/getContinuationRegionList")
    @LogRecord(description = "查询续交小区列表", operationUnit = LogOperationUnit.DEPOSIT_CONTINUATION, operationType = LogOperationType.UPDATE)
    public PageInfo<BaseRegionInfo> getContinuationRegionList(Page page, BaseRegionInfo baseRegionInfo) {
        return depositContinuationService.getContinuationRegionList(page, baseRegionInfo);
    }

    /**
     * 查询续交自然幢列表
     *
     * @param page          分页信息
     * @param baseBuildInfo 查询信息
     * @return 续交自然幢列表
     */
    @PostMapping("/getContinuationBuildList")
    @LogRecord(description = "查询续交自然幢列表", operationUnit = LogOperationUnit.DEPOSIT_CONTINUATION, operationType = LogOperationType.UPDATE)
    public PageInfo<BaseBuildInfo> getContinuationBuildList(Page page, BaseBuildInfo baseBuildInfo) {
        return depositContinuationService.getContinuationBuildList(page, baseBuildInfo);
    }

    /**
     * 批量查询续交房屋列表
     *
     * @param page          分页信息
     * @param baseHouseInfo 查询信息
     * @return 续交房屋列表
     */
    @PostMapping("/getContinuationHouseList")
    @LogRecord(description = "批量查询续交房屋列表", operationUnit = LogOperationUnit.DEPOSIT_CONTINUATION, operationType = LogOperationType.UPDATE)
    public PageInfo<BaseHouseInfo> getContinuationHouseList(Page page, BaseHouseInfo baseHouseInfo) {
        return depositContinuationService.getContinuationHouseList(page, baseHouseInfo);
    }

    /**
     * 查询单个自然幢续交房屋列表
     *
     * @param page          分页信息
     * @param baseHouseInfo 查询信息
     * @return 续交房屋列表
     */
    @PostMapping("/getSignalContinuationHouseList")
    @LogRecord(description = "查询单个自然幢续交房屋列表", operationUnit = LogOperationUnit.DEPOSIT_CONTINUATION, operationType = LogOperationType.UPDATE)
    public PageInfo<BaseHouseInfo> getSignalContinuationHouseList(Page page, BaseHouseInfo baseHouseInfo) {
        return depositContinuationService.getSignalContinuationHouseList(page, baseHouseInfo);
    }

    /**
     * 查询续交模式下拉列表
     *
     * @param depModeInfo 查询信息
     * @return 续交下拉列表
     */
    @PostMapping("/getModeList")
    @LogRecord(description = "查询续交模式下拉列表", operationUnit = LogOperationUnit.DEPOSIT_CONTINUATION, operationType = LogOperationType.UPDATE)
    public List<DepModeInfo> getModeList(DepModeInfo depModeInfo) {
        return depositContinuationService.getModeList(depModeInfo);
    }

    /**
     * 重置交存模式
     *
     * @param houseId 房间ID
     * @return 重置结果
     */
    @PostMapping("/resetModeType")
    @LogRecord(description = "重置交存模式", operationUnit = LogOperationUnit.DEPOSIT_CONTINUATION, operationType = LogOperationType.UPDATE)
    public CommonResult resetModeType(String houseId) {
        return depositContinuationService.resetModeType(houseId);
    }

    /**
     * 维护交存模式
     *
     * @param list 维护的交存模式房间集合
     * @return 维护结果
     */
    @PostMapping("/setModeType")
    @LogRecord(description = "维护交存模式", operationUnit = LogOperationUnit.DEPOSIT_CONTINUATION, operationType = LogOperationType.UPDATE)
    public CommonResult setModeType(@RequestBody List<DepNotice> list) {
        return depositContinuationService.setModeType(list);
    }

    /**
     * 续交申请
     *
     * @param depositContinuation 续交房间集合
     * @return 续交结果
     */
    @PostMapping("/apply")
    @LogRecord(description = "续交申请", operationUnit = LogOperationUnit.DEPOSIT_CONTINUATION, operationType = LogOperationType.UPDATE)
    public CommonResult apply(@RequestBody DepositContinuation depositContinuation) {
        return depositContinuationService.apply(depositContinuation);
    }

    /**
     * 查询续交待审核列表
     *
     * @param page          分页信息
     * @param baseHouseInfo 查询实体
     * @return 续交待审核列表
     */
    @RequestMapping("/getAuditList")
    @LogRecord(description = "查询续交待审核列表", operationUnit = LogOperationUnit.DEPOSIT_CONTINUATION, operationType = LogOperationType.SELECT)
    public PageInfo<BaseHouseInfo> getAuditList(Page page, BaseHouseInfo baseHouseInfo) {
        return depositContinuationService.getAuditList(page, baseHouseInfo);
    }

    /**
     * 续交审核
     *
     * @param depositAuditRequest list    审核ID
     *                            opinion 审批意见
     *                            mark    审批通过 audit_pass
     *                            审批否决 audit_veto
     *                            审批退回 audit_back
     * @return 操作结果
     */
    @RequestMapping("/audit")
    @LogRecord(description = "续交审核", operationUnit = LogOperationUnit.DEPOSIT, operationType = LogOperationType.UPDATE)
    public CommonResult audit(@RequestBody DepositAuditRequest depositAuditRequest) {
        return depositContinuationService.audit(depositAuditRequest);
    }

    /**
     * 续交查询列表
     *
     * @param page          分页信息
     * @param baseHouseInfo 查询实体
     * @return 续交待审核列表
     */
    @RequestMapping("/searchAuditList")
    @LogRecord(description = "续交查询列表", operationUnit = LogOperationUnit.DEPOSIT_CONTINUATION, operationType = LogOperationType.SELECT)
    public PageInfo<BaseHouseInfo> searchAuditList(Page page, BaseHouseInfo baseHouseInfo) {
        return depositContinuationService.searchAuditList(page, baseHouseInfo);
    }

    /**
     * 查询续交撤销列表
     *
     * @param page          分页信息
     * @param baseHouseInfo 查询实体
     * @return 续交撤销列表
     */
    @RequestMapping("/getRevocationList")
    @LogRecord(description = "查询续交撤销列表", operationUnit = LogOperationUnit.DEPOSIT_CONTINUATION, operationType = LogOperationType.SELECT)
    public PageInfo<BaseHouseInfo> getRevocationList(Page page, BaseHouseInfo baseHouseInfo) {
        return depositContinuationService.getRevocationList(page, baseHouseInfo);
    }

    /**
     * 续交撤销查询
     *
     * @param page          分页信息
     * @param baseHouseInfo 查询实体
     * @return 续交撤销查询
     */
    @RequestMapping("/searchRevocationList")
    @LogRecord(description = "续交撤销查询", operationUnit = LogOperationUnit.DEPOSIT_CONTINUATION, operationType = LogOperationType.SELECT)
    public PageInfo<BaseHouseInfo> searchRevocationList(Page page, BaseHouseInfo baseHouseInfo) {
        return depositContinuationService.searchRevocationList(page, baseHouseInfo);
    }

    /**
     * 续交撤销
     *
     * @param list 撤销ID集合
     * @return 撤销结果
     */
    @PostMapping("/revocation")
    public CommonResult revocation(@RequestBody List<String> list) {
        return depositContinuationService.revocation(list);
    }
}
